<template>
  <div class="user-milestone-container">
    <div class="page-header">
      <h1>我的成就</h1>
      <p>查看您已达成的戒烟里程碑和成就记录</p>
    </div>

    <!-- 成就概览 -->
    <div class="achievement-overview">
      <div class="overview-card">
        <div class="overview-stats">
          <div class="stat-item">
            <h2>{{ achievedCount }}</h2>
            <p>已达成里程碑</p>
          </div>
          <div class="stat-item">
            <h2>{{ totalDays }}</h2>
            <p>累计戒烟天数</p>
          </div>
          <div class="stat-item">
            <h2>{{ latestAchievement?.name || '-' }}</h2>
            <p>最新成就</p>
          </div>
        </div>
        
        <div class="achievement-progress">
          <div class="progress-circle">
            <svg width="120" height="120" viewBox="0 0 120 120">
              <circle cx="60" cy="60" r="50" fill="none" stroke="#e0e0e0" stroke-width="8" />
              <circle
                cx="60"
                cy="60"
                r="50"
                fill="none"
                stroke="#28a745"
                stroke-width="8"
                stroke-linecap="round"
                :stroke-dasharray="circumference"
                :stroke-dashoffset="circumference - (achievementRate / 100) * circumference"
                transform="rotate(-90 60 60)"
              />
            </svg>
            <div class="progress-text">
              <span class="percentage">{{ Math.round(achievementRate) }}%</span>
              <span class="label">完成率</span>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 成就展示 -->
    <div class="achievements-section">
      <h2>成就展示</h2>
      
      <div class="achievements-grid">
        <div
          v-for="achievement in userMilestones"
          :key="achievement.id"
          class="achievement-card achieved"
          @click="viewAchievementDetail(achievement)"
        >
          <div class="achievement-badge">
            <div class="badge-icon">🏆</div>
          </div>
          
          <div class="achievement-content">
            <h3>{{ achievement.milestone.name }}</h3>
            <p class="achievement-description">{{ achievement.milestone.description }}</p>
            
            <div class="achievement-meta">
              <span class="achievement-days">{{ achievement.milestone.days }} 天</span>
              <span class="achievement-date">{{ formatDate(achievement.achieved_date) }}</span>
            </div>
            
            <div class="reward-message">
              <span class="reward-icon">🎉</span>
              {{ achievement.milestone.reward_message }}
            </div>
          </div>
        </div>
      </div>
      
      <!-- 未达成的里程碑 -->
      <div v-if="upcomingMilestones.length > 0" class="upcoming-section">
        <h3>即将达成</h3>
        <div class="upcoming-grid">
          <div
            v-for="milestone in upcomingMilestones"
            :key="milestone.id"
            class="achievement-card upcoming"
          >
            <div class="achievement-badge upcoming-badge">
              <div class="badge-icon">🎯</div>
            </div>
            
            <div class="achievement-content">
              <h3>{{ milestone.name }}</h3>
              <p class="achievement-description">{{ milestone.description }}</p>
              
              <div class="achievement-meta">
                <span class="achievement-days">{{ milestone.days }} 天</span>
                <span class="days-remaining">还需 {{ milestone.days - currentDays }} 天</span>
              </div>
              
              <div class="progress-to-goal">
                <div class="progress-bar">
                  <div
                    class="progress-fill"
                    :style="{ width: getProgressToMilestone(milestone) + '%' }"
                  ></div>
                </div>
                <span class="progress-percentage">{{ Math.round(getProgressToMilestone(milestone)) }}%</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 成就时间轴 -->
    <div class="timeline-section">
      <h2>成就时间轴</h2>
      
      <div class="timeline">
        <div
          v-for="(achievement, index) in sortedAchievements"
          :key="achievement.id"
          class="timeline-item"
        >
          <div class="timeline-dot">
            <span class="timeline-icon">🏆</span>
          </div>
          
          <div class="timeline-content">
            <div class="timeline-header">
              <h4>{{ achievement.milestone.name }}</h4>
              <span class="timeline-date">{{ formatDate(achievement.achieved_date) }}</span>
            </div>
            
            <p class="timeline-description">{{ achievement.milestone.description }}</p>
            
            <div class="timeline-reward">
              {{ achievement.milestone.reward_message }}
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 分享成就 -->
    <div class="share-section">
      <h2>分享我的成就</h2>
      
      <div class="share-card">
        <div class="share-preview">
          <h3>我的戒烟成就</h3>
          <p>我已经成功戒烟 <strong>{{ currentDays }}</strong> 天！</p>
          <p>已达成 <strong>{{ achievedCount }}</strong> 个里程碑</p>
          
          <div class="achievement-badges">
            <div
              v-for="achievement in userMilestones.slice(0, 3)"
              :key="achievement.id"
              class="mini-badge"
            >
              🏆 {{ achievement.milestone.name }}
            </div>
          </div>
        </div>
        
        <div class="share-actions">
          <button @click="shareAchievements" class="share-btn">
            📤 分享成就
          </button>
          <button @click="downloadCertificate" class="certificate-btn">
            📜 生成证书
          </button>
        </div>
      </div>
    </div>

    <!-- 提示信息 -->
    <div v-if="error" class="error-message">{{ error }}</div>
    <div v-if="successMessage" class="success-message">{{ successMessage }}</div>
  </div>
</template>

<script>
import { userMilestoneApi, milestoneApi } from '../api/index.js'

export default {
  name: 'UserMilestoneView',
  data() {
    return {
      userMilestones: [],
      allMilestones: [],
      selectedAchievement: null,
      currentDays: 6,
      loading: false,
      error: '',
      successMessage: ''
    }
  },

  computed: {
    circumference() {
      return 2 * Math.PI * 50
    },

    achievedCount() {
      return this.userMilestones.length
    },

    totalDays() {
      return this.currentDays
    },

    latestAchievement() {
      if (this.userMilestones.length === 0) return null
      return this.sortedAchievements[0]?.milestone
    },

    achievementRate() {
      if (this.allMilestones.length === 0) return 0
      return (this.achievedCount / this.allMilestones.length) * 100
    },

    sortedAchievements() {
      return [...this.userMilestones].sort((a, b) => 
        new Date(b.achieved_date) - new Date(a.achieved_date)
      )
    },

    upcomingMilestones() {
      const achievedMilestoneIds = this.userMilestones.map(um => um.milestone.id)
      return this.allMilestones
        .filter(m => !achievedMilestoneIds.includes(m.id) && m.days > this.currentDays)
        .sort((a, b) => a.days - b.days)
        .slice(0, 3)
    }
  },

  async mounted() {
    await this.loadData()
  },

  methods: {
    async loadData() {
      this.loading = true
      this.error = ''
      
      try {
        await Promise.all([
          this.loadUserMilestones(),
          this.loadAllMilestones()
        ])
        
      } catch (error) {
        console.error('加载数据失败:', error)
        this.error = '加载数据失败，请稍后重试'
      } finally {
        this.loading = false
      }
    },

    async loadUserMilestones() {
      console.log('加载用户成就...')
      await new Promise(resolve => setTimeout(resolve, 800))
      
      // 为 UserMilestoneView 添加不同的假数据
      this.userMilestones = [
        {
          id: 1,
          milestone: {
            id: 1,
            name: '戒烟先锋',
            days: 1,
            description: '成功度过戒烟第一天，这是最重要的里程碑！',
            reward_message: '你已经迈出了改变人生的第一步！'
          },
          achieved_date: '2024-09-01T09:00:00'
        },
        {
          id: 2,
          milestone: {
            id: 3,
            name: '坚持勇士',
            days: 7,
            description: '成功坚持一周无烟生活，你的意志力令人敬佩！',
            reward_message: '一周的坚持，你的身体已经开始恢复了！'
          },
          achieved_date: '2024-09-07T08:30:00'
        }
      ]
    },

    async loadAllMilestones() {
      console.log('加载所有里程碑...')
      await new Promise(resolve => setTimeout(resolve, 600))
      
      // 为 UserMilestoneView 添加不同的假数据
      this.allMilestones = [
        {
          id: 1,
          name: '戒烟先锋',
          days: 1,
          description: '成功度过戒烟第一天',
          reward_message: '迈出了改变人生的第一步！'
        },
        {
          id: 2,
          name: '三日挑战者',
          days: 3,
          description: '成功度过戒烟前三天',
          reward_message: '最难的三天已经过去！'
        },
        {
          id: 3,
          name: '坚持勇士',
          days: 7,
          description: '成功坚持一周无烟生活',
          reward_message: '你的意志力令人敬佩！'
        },
        {
          id: 4,
          name: '半月达人',
          days: 15,
          description: '成功坚持半个月无烟生活',
          reward_message: '你已经超越了大多数人！'
        },
        {
          id: 5,
          name: '月度之星',
          days: 30,
          description: '成功坚持一个月无烟生活',
          reward_message: '你的身体正在感谢你的决定！'
        },
        {
          id: 6,
          name: '季度冠军',
          days: 90,
          description: '成功坚持一个季度无烟生活',
          reward_message: '你已经是一个全新的自己！'
        },
        {
          id: 7,
          name: '半年传奇',
          days: 180,
          description: '成功坚持半年无烟生活',
          reward_message: '你的毅力令人惊叹！'
        },
        {
          id: 8,
          name: '年度英雄',
          days: 365,
          description: '成功坚持一年无烟生活',
          reward_message: '你是真正的戒烟英雄！'
        }
      ]
    },

    viewAchievementDetail(achievement) {
      this.selectedAchievement = achievement
    },

    getProgressToMilestone(milestone) {
      const previousMilestone = this.allMilestones
        .filter(m => m.days <= this.currentDays)
        .sort((a, b) => b.days - a.days)[0]
      
      const startDays = previousMilestone ? previousMilestone.days : 0
      const totalDays = milestone.days - startDays
      const currentProgress = this.currentDays - startDays
      
      return Math.min((currentProgress / totalDays) * 100, 100)
    },

    shareAchievements() {
      const shareText = `我已经成功戒烟${this.currentDays}天，达成了${this.achievedCount}个里程碑！${this.userMilestones.map(a => `🏆 ${a.milestone.name}`).join(' ')}`
      
      if (navigator.share) {
        navigator.share({
          title: '我的戒烟成就',
          text: shareText
        })
      } else {
        navigator.clipboard.writeText(shareText)
        this.successMessage = '成就已复制到剪贴板！'
        setTimeout(() => { this.successMessage = '' }, 3000)
      }
    },

    downloadCertificate() {
      console.log('生成戒烟证书...')
      this.successMessage = '证书生成功能开发中...'
      setTimeout(() => { this.successMessage = '' }, 3000)
    },

    formatDate(dateString) {
      return new Date(dateString).toLocaleDateString('zh-CN', {
        year: 'numeric',
        month: '2-digit',
        day: '2-digit'
      })
    }
  }
}
</script>

<style scoped>
.user-milestone-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  background: linear-gradient(135deg, #faf0ff 0%, #f0f9ff 100%);
  position: relative;
  overflow: hidden;
  font-family: '方正准圆简体', '站酷快乐体', 'Comic Sans MS', cursive, sans-serif;
}

/* 添加漂浮装饰元素 */
.user-milestone-container::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(255, 198, 255, 0.2) 3px, transparent 3px),
    radial-gradient(circle at 90% 40%, rgba(180, 248, 200, 0.2) 2px, transparent 2px),
    radial-gradient(circle at 40% 80%, rgba(255, 209, 220, 0.2) 4px, transparent 4px),
    radial-gradient(circle at 70% 15%, rgba(162, 210, 255, 0.2) 3px, transparent 3px),
    radial-gradient(circle at 20% 70%, rgba(255, 175, 204, 0.2) 2px, transparent 2px),
    radial-gradient(circle at 85% 25%, rgba(255, 209, 220, 0.2) 3px, transparent 3px);
  background-size: 200px 200px;
  z-index: 0;
}

.user-milestone-container > * {
  position: relative;
  z-index: 1;
}

.page-header {
  text-align: center;
  margin-bottom: 40px;
  animation: slideInDown 0.8s ease-out;
}

.page-header h1 {
  color: #444444;
  margin-bottom: 10px;
  font-size: 28px;
  font-weight: 500;
  font-family: '方正准圆简体', '站酷快乐体', 'Comic Sans MS', cursive, sans-serif;
}

.page-header p {
  color: #888888;
  font-size: 16px;
  font-weight: 400;
  font-family: '方正准圆简体', '站酷快乐体', 'Comic Sans MS', cursive, sans-serif;
}

.achievement-overview {
  margin-bottom: 40px;
}

.overview-card {
  background: linear-gradient(135deg, #A2D2FF 0%, #CDB4DB 100%);
  color: white;
  border-radius: 20px;
  padding: 30px;
  display: flex;
  align-items: center;
  gap: 30px;
  box-shadow: 0 8px 25px rgba(162, 210, 255, 0.4);
  border: 2px solid #A2D2FF;
  position: relative;
  overflow: hidden;
  animation: slideInUp 0.6s ease-out;
}

.overview-card::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 70%);
  transform: rotate(30deg);
}

.overview-stats {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.stat-item {
  text-align: center;
  padding: 15px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 15px;
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.stat-item h2 {
  font-size: 32px;
  margin: 0 0 5px 0;
  font-weight: bold;
  font-family: '方正准圆简体', '站酷快乐体', 'Comic Sans MS', cursive, sans-serif;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stat-item p {
  font-size: 14px;
  margin: 0;
  opacity: 0.9;
  font-family: '方正准圆简体', '站酷快乐体', 'Comic Sans MS', cursive, sans-serif;
}

.achievement-progress {
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-circle {
  position: relative;
  width: 120px;
  height: 120px;
}

.progress-circle svg circle:first-child {
  stroke: rgba(255, 255, 255, 0.3);
}

.progress-circle svg circle:last-child {
  stroke: #B4F8C8;
  filter: drop-shadow(0 0 5px rgba(180, 248, 200, 0.5));
}

.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.progress-text .percentage {
  font-size: 20px;
  font-weight: bold;
  display: block;
  font-family: '方正准圆简体', '站酷快乐体', 'Comic Sans MS', cursive, sans-serif;
}

.progress-text .label {
  font-size: 12px;
  opacity: 0.9;
  font-family: '方正准圆简体', '站酷快乐体', 'Comic Sans MS', cursive, sans-serif;
}

.achievements-section,
.timeline-section,
.share-section {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(5px);
  border-radius: 20px;
  padding: 30px;
  margin-bottom: 30px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  border: 2px solid #A2D2FF;
  position: relative;
  overflow: hidden;
  animation: slideInUp 0.8s ease-out;
}

.achievements-section::after,
.timeline-section::after,
.share-section::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, #FFD1DC, #A2D2FF);
  border-radius: 0 0 20px 20px;
}

.achievements-section h2,
.timeline-section h2,
.share-section h2 {
  color: #444444;
  margin-bottom: 25px;
  text-align: center;
  font-family: '方正准圆简体', '站酷快乐体', 'Comic Sans MS', cursive, sans-serif;
}

.achievements-grid,
.upcoming-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.upcoming-section {
  margin-top: 40px;
}

.upcoming-section h3 {
  color: #444444;
  margin-bottom: 20px;
  font-family: '方正准圆简体', '站酷快乐体', 'Comic Sans MS', cursive, sans-serif;
}

.achievement-card {
  border-radius: 20px;
  padding: 25px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(5px);
}

.achievement-card::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  border-radius: 0 0 20px 20px;
}

.achievement-card.achieved {
  background: rgba(240, 255, 244, 0.9);
  border: 2px solid #B4F8C8;
  box-shadow: 0 8px 25px rgba(180, 248, 200, 0.2);
}

.achievement-card.achieved::after {
  background: linear-gradient(90deg, #B4F8C8, #94e8a8);
}

.achievement-card.upcoming {
  background: rgba(255, 240, 245, 0.9);
  border: 2px solid #FFD1DC;
  box-shadow: 0 8px 25px rgba(255, 209, 220, 0.2);
}

.achievement-card.upcoming::after {
  background: linear-gradient(90deg, #FFD1DC, #FFAFCC);
}

.achievement-card:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

.achievement-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  z-index: 2;
}

.achievement-badge.achieved {
  background: #B4F8C8;
}

.achievement-badge.upcoming-badge {
  background: #FFD1DC;
}

.badge-icon {
  font-size: 24px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.achievement-content {
  padding-right: 50px;
}

.achievement-content h3 {
  color: #444444;
  margin-bottom: 10px;
  font-size: 20px;
  font-family: '方正准圆简体', '站酷快乐体', 'Comic Sans MS', cursive, sans-serif;
}

.achievement-description {
  color: #666666;
  margin-bottom: 15px;
  line-height: 1.5;
  font-family: '方正准圆简体', '站酷快乐体', 'Comic Sans MS', cursive, sans-serif;
}

.achievement-meta {
  display: flex;
  gap: 15px;
  margin-bottom: 15px;
  font-size: 14px;
  font-family: '方正准圆简体', '站酷快乐体', 'Comic Sans MS', cursive, sans-serif;
}

.achievement-days {
  background: #f8f9fa;
  color: #495057;
  padding: 6px 12px;
  border-radius: 15px;
  font-weight: 500;
}

.achievement-date {
  color: #B4F8C8;
  font-weight: 500;
}

.days-remaining {
  color: #FFD1DC;
  font-weight: 500;
}

.reward-message {
  background: rgba(180, 248, 200, 0.2);
  color: #2e8b57;
  padding: 12px;
  border-radius: 12px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: '方正准圆简体', '站酷快乐体', 'Comic Sans MS', cursive, sans-serif;
  border: 1px dashed #B4F8C8;
}

.reward-icon {
  font-size: 16px;
}

.progress-to-goal {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 15px;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: rgba(255, 209, 220, 0.3);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 209, 220, 0.5);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #FFD1DC, #FFAFCC);
  border-radius: 4px;
  transition: width 0.5s ease;
  box-shadow: 0 0 5px rgba(255, 209, 220, 0.5);
}

.progress-percentage {
  font-size: 12px;
  color: #FFAFCC;
  font-weight: 500;
  min-width: 35px;
  font-family: '方正准圆简体', '站酷快乐体', 'Comic Sans MS', cursive, sans-serif;
}

.timeline {
  position: relative;
  padding-left: 40px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 20px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(to bottom, #B4F8C8, #FFD1DC);
  border-radius: 3px;
}

.timeline-item {
  position: relative;
  margin-bottom: 30px;
  padding-left: 40px;
}

.timeline-dot {
  position: absolute;
  left: -30px;
  top: 5px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #B4F8C8;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 4px white, 0 4px 10px rgba(180, 248, 200, 0.4);
  animation: float 3s ease-in-out infinite;
}

.timeline-icon {
  font-size: 20px;
  color: white;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.1));
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.timeline-header h4 {
  color: #444444;
  margin: 0;
  font-size: 18px;
  font-family: '方正准圆简体', '站酷快乐体', 'Comic Sans MS', cursive, sans-serif;
}

.timeline-date {
  color: #888888;
  font-size: 14px;
  font-family: '方正准圆简体', '站酷快乐体', 'Comic Sans MS', cursive, sans-serif;
}

.timeline-description {
  color: #666666;
  margin-bottom: 10px;
  line-height: 1.5;
  font-family: '方正准圆简体', '站酷快乐体', 'Comic Sans MS', cursive, sans-serif;
}

.timeline-reward {
  background: rgba(180, 248, 200, 0.2);
  color: #2e8b57;
  padding: 12px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 10px;
  font-family: '方正准圆简体', '站酷快乐体', 'Comic Sans MS', cursive, sans-serif;
  border: 1px dashed #B4F8C8;
}

.share-card {
  display: flex;
  gap: 30px;
  align-items: center;
}

.share-preview {
  flex: 1;
  padding: 25px;
  border-radius: 15px;
  background: linear-gradient(135deg, #FFD1DC 0%, #A2D2FF 100%);
  color: #444444;
  box-shadow: 0 8px 25px rgba(255, 209, 220, 0.3);
  border: 2px solid #FFD1DC;
}

.share-preview h3 {
  color: #444444;
  margin-bottom: 15px;
  font-family: '方正准圆简体', '站酷快乐体', 'Comic Sans MS', cursive, sans-serif;
}

.share-preview p {
  color: #444444;
  margin-bottom: 10px;
  line-height: 1.5;
  font-family: '方正准圆简体', '站酷快乐体', 'Comic Sans MS', cursive, sans-serif;
}

.achievement-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 15px;
}

.mini-badge {
  background: rgba(255, 255, 255, 0.8);
  color: #444444;
  padding: 6px 12px;
  border-radius: 15px;
  font-size: 12px;
  font-family: '方正准圆简体', '站酷快乐体', 'Comic Sans MS', cursive, sans-serif;
  border: 1px solid rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(5px);
}

.share-actions {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.share-btn,
.certificate-btn {
  padding: 15px 25px;
  border: 2px solid white;
  border-radius: 25px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
  font-family: '方正准圆简体', '站酷快乐体', 'Comic Sans MS', cursive, sans-serif;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.share-btn {
  background: #A2D2FF;
  color: white;
}

.share-btn:hover {
  background: transparent;
  color: #A2D2FF;
  border-color: #A2D2FF;
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 6px 15px rgba(162, 210, 255, 0.4);
}

.certificate-btn {
  background: #FFD1DC;
  color: #444444;
}

.certificate-btn:hover {
  background: transparent;
  color: #FFD1DC;
  border-color: #FFD1DC;
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 6px 15px rgba(255, 209, 220, 0.4);
}

/* 动画效果 */
@keyframes slideInUp {
  from {
    transform: translate3d(0, 100%, 0);
    visibility: visible;
  }
  to {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes slideInDown {
  from {
    transform: translate3d(0, -100%, 0);
    visibility: visible;
  }
  to {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  }
}

@media (max-width: 768px) {
  .user-milestone-container {
    padding: 15px;
  }
  
  .overview-card {
    flex-direction: column;
    gap: 20px;
  }
  
  .overview-stats {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .achievements-grid,
  .upcoming-grid {
    grid-template-columns: 1fr;
  }
  
  .share-card {
    flex-direction: column;
    gap: 20px;
  }
  
  .page-header h1 {
    font-size: 24px;
  }
  
  .timeline {
    padding-left: 30px;
  }
  
  .timeline-dot {
    left: -25px;
    width: 35px;
    height: 35px;
  }
  
  .stat-item {
    padding: 12px;
  }
  
  .stat-item h2 {
    font-size: 28px;
  }
  
  .share-preview {
    padding: 20px;
  }
}
</style>